﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Drawing;
using System.Drawing.Drawing2D;

namespace SimpleBomberman
{
    public class Level
    {
        #region Members

        private List<CementWall> _cementWallList;
        private List<BrickWall> _brickWallList;
        private List<Enemy> _enemyList;
        private ExitDoor _exitDoor;
        private Bonus _bonus;

        private int _points;
        private int _time;

        #endregion Members

        #region Properties

        public List<CementWall> CementWallList
        {
            get
            {
                return this._cementWallList;
            }
            set
            {
                this._cementWallList = value;
            }
        }
        public List<BrickWall> BrickWallList
        {
            get
            {
                return this._brickWallList;
            }
            set
            {
                this._brickWallList = value;
            }
        }
        public List<Enemy> EnemyList
        {
            get
            {
                return this._enemyList;
            }
            set
            {
                this._enemyList = value;
            }
        }
        public ExitDoor ExitDoor
        {
            get
            {
                return this._exitDoor;
            }
            set
            {
                this._exitDoor = value;
            }
        }
        public Bonus Bonus
        {
            get
            {
                return this._bonus;
            }
            set
            {
                this._bonus = value;
            }
        }
        public int Points
        {
            get
            {
                return this._points;
            }
            set
            {
                this._points = value;
            }
        }
        public int Time
        {
            get
            {
                return this._time;
            }
            set
            {
                this._time = value;
            }
        }

        #endregion Properties

        #region Constructors

        public Level()
        {
            this._cementWallList = new List<CementWall>();
            this._brickWallList = new List<BrickWall>();
            this._enemyList = new List<Enemy>();
            this._exitDoor = new ExitDoor();
            this._bonus = new Bonus();

            this._points = 0;
            this._time = 0;
        }

        #endregion Constructors

        #region Public Methods

        public void FillLevel(int[,] matrix)
        {
            for (int i = 0; i < matrix.GetLength(0); i++)
            {
                for (int j = 0; j < matrix.GetLength(1); j++)
                {
                    //--- CementWall ---
                    if (matrix[i, j] == 1)
                    {
                        this._cementWallList.Add(new CementWall(j * 30, i * 30, 30));
                    }
                    //--- BrickWall ---
                    if (matrix[i, j] == 2)
                    {
                        this._brickWallList.Add(new BrickWall(j * 30, i * 30, 30));
                    }
                    //--- Enemy ---
                    if (matrix[i, j] == 3)
                    {
                        this._enemyList.Add(new Enemy(j * 30, i * 30, 30));
                    }
                    //--- ExitDoor ---
                    if (matrix[i, j] == 4)
                    {
                        this._exitDoor.X = j * 30;
                        this._exitDoor.Y = i * 30;
                        this._exitDoor.Length = 30;
                    }
                    //--- Bonus ---
                    if (matrix[i, j] == 5)
                    {
                        this._bonus.X = j * 30;
                        this._bonus.Y = i * 30;
                        this._bonus.Length = 30;
                    }
                }
            }
        }
        public void DrawLevel(Graphics g)
        {
            for (int i = 0; i < this._cementWallList.Count; i++)
            {
                this._cementWallList[i].Draw(g);
            }
            for (int i = 0; i < this._brickWallList.Count; i++)
            {
                this._brickWallList[i].Draw(g);
            }
            for (int i = 0; i < this._enemyList.Count; i++)
            {
                this._enemyList[i].Draw(g);
            }
            this._exitDoor.Draw(g);
            this._bonus.Draw(g);
        }

        #endregion Public Methods
    }
}
